# @LICENSE(NICTA_CORE)

# Targets
PRIORITY_TARGETS := include/interfaces/sel4_client.h
TARGETS          := libsel4.a

# Source files required to build the target
CFILES := \
	$(patsubst $(SOURCE_DIR)/%,%,$(wildcard $(SOURCE_DIR)/src/*.c)) \
	$(patsubst $(SOURCE_DIR)/%,%,$(wildcard $(SOURCE_DIR)/src/arch-$(ARCH)/*.c))

# Header files/directories this library provides
# Note: sel4_client.h may not have been built at the time this is evaluated.
HDRFILES := \
	$(wildcard $(SOURCE_DIR)/include/*) \
	$(wildcard $(SOURCE_DIR)/arch_include/$(ARCH)/*) \
	$(BUILD_DIR)/include/interfaces #TODO proper prefix instruction

.DEFAULT_GOAL := default

install-headers: ${PRIORITY_TARGETS}

# Extra include directory for magpie to find type.h and sel4arch.idl4
INCLUDE_DIRS := include arch_include/$(ARCH)

include $(SEL4_COMMON)/common.mk

# Stub generator
include/interfaces/sel4_client.h: \
		${SOURCE_DIR}/arch_include/${ARCH}/interfaces/sel4arch.xml \
		${SOURCE_DIR}/include/interfaces/sel4.xml \
		| ${DIRECTORIES}
	@echo "[STUB_GEN] $@"
	@python ${SOURCE_DIR}/tools/syscall_stub_gen.py -a $(ARCH) -o $@ $^
